import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.io.FileUtils;
import org.jsoup.Connection;
import org.jsoup.Jsoup;

import java.io.File;
import java.io.IOException;

/**
 * Created by abely on 16-2-17.
 */
public class Demo {
    public static void main(String[] args) throws IOException {
        String url = "http://image.baidu.com/search/avatarjson?tn=resultjsonavatarnew&ie=utf-8&word=%E5%A3%81%E7%BA%B8&cg=wallpaper&pn=0&rn=60&itg=0&z=0&fr=&width=&height=&lm=-1&ic=0&s=0&st=-1&gsm=60000001e";
        Connection.Response response = Jsoup.connect(url).execute();
        //将得到的字符串转换为JSON类型
        JSONObject jsonObject = JSONObject.parseObject(response.body());
        //得到所有的img
        JSONArray jsonArray = JSONObject.parseArray(jsonObject.get("imgs").toString());
        for (int i = 0; i < jsonArray.size(); i++) {
            String url2 = JSONObject.parseObject(jsonArray.get(i).toString()).get("objURL").toString();
            System.out.println(url2);
        }
        System.out.println(jsonArray.size());
    }
}
